//
// Created by 崔世强 on 2018/3/8.
// Copyright (c) 2018 Facebook. All rights reserved.
//

import Foundation
import UIKit
import SnapKit

class ChatMoreViewCell: UICollectionViewCell {
    lazy var itemButton: UIButton = {
        let itemBtn = UIButton()
        itemBtn.backgroundColor = .systemGray5
        itemBtn.isUserInteractionEnabled = false
        itemBtn.layer.cornerRadius = 10
        itemBtn.layer.masksToBounds = true
//        itemBtn.layer.borderColor = UIColor.lightGray.cgColor
        itemBtn.layer.borderWidth = 0
        return itemBtn
    }()

    lazy var itemLabel: UILabel = {
        let itemL = UILabel()
        itemL.textColor = UIColor.gray
        itemL.font = UIFont.systemFont(ofSize: 11.0)
        itemL.textAlignment = .center
        return itemL
    }()

    var type: ChatMoreType?

    // MARK:- 记录属性
    var model: (name: String, icon: UIImage, type: ChatMoreType)? {
        didSet {
            self.itemButton.setImage(model?.icon, for: .normal)
            self.itemLabel.text = model?.name
            self.type = model?.type
        }
    }

    override func layoutSubviews() {
        super.layoutSubviews()

        self.addSubview(itemButton)
        self.addSubview(itemLabel)

        itemLabel.snp.makeConstraints { (make) in
            make.left.right.equalTo(self)
            make.bottom.equalTo(self.snp.bottom).offset(-10)
        }
        itemButton.snp.makeConstraints { (make) in
            make.width.height.equalTo(56)
            make.bottom.equalTo(itemLabel.snp.top).offset(-5)
            make.centerX.equalTo(self.snp.centerX)
        }

    }
}
